package com.tistory.iam1492.network;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.graphics.Bitmap;
import android.util.Log;

import com.tistory.iam1492.beans.StarDetailBean;
import com.tistory.iam1492.beans.StarListBean;
import com.tistory.iam1492.util.ImageUtil;
import com.tistory.iam1492.util.SRVariables;

public class SRDetailJSONParser {
	public StarDetailBean getSRDetail(String jsonResponse){
		JSONObject root = null;
		JSONObject detailObj = null;

		try {
			root = new JSONObject(jsonResponse);
			if (root.has("starDetail")){
				detailObj = root.getJSONObject("starDetail");

				int listingId;
				String name;
				int age;
				String pic;
				int type;
				String job;
				String carrier;
				int height;
				int weight;
				String company;
				String homepage;

				listingId = (detailObj.has("listingId"))?detailObj.getInt("listingId"):null;
				name = (detailObj.has("name"))?detailObj.getString("name"):null;
				age = (detailObj.has("age"))?detailObj.getInt("age"):null;
				pic = (detailObj.has("pic"))?detailObj.getString("pic"):null;
				type = (detailObj.has("vote"))?detailObj.getInt("type"):null;
				height = (detailObj.has("height"))?detailObj.getInt("height"):null;
				weight = (detailObj.has("weight"))?detailObj.getInt("weight"):null;
				job = (detailObj.has("job"))?detailObj.getString("job"):null;
				carrier = (detailObj.has("carrier"))?detailObj.getString("carrier"):null;
				company = (detailObj.has("company"))?detailObj.getString("company"):null;
				homepage = (detailObj.has("homepage"))?detailObj.getString("homepage"):null;

				Log.e("JSONParser", "Name:"+name+" listingId:"+listingId);
				StarDetailBean cb = new StarDetailBean();
				cb.setAge(age);
				cb.setListingId(listingId);
				cb.setName(name);
				cb.setPic(pic);
				cb.setType(type);
				cb.setHeight(height);
				cb.setWeight(weight);
				cb.setJob(job);
				cb.setCompany(company);
				cb.setHomepage(homepage);
				cb.setCarrier(carrier);
				return cb;
			}	

		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;		
	}
}
